<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors',true);
$pthRoot = dirname(__FILE__);

define("DONT_RUN_APP",true);
require(realpath('./../public/index.php'));

try {
    $opts = new Zend_Console_Getopt(
        array(
            'help|h' => 'Displays usage information.',
            'action|a=s' => 'Action to perform in format of module.controller.action',
            'verbose|v' => 'Verbose messages will be dumped to the default output.',
            'development|d' => 'Enables development mode.',
            'test|t' => 'Enables development mode.',
        )
    );
    $opts->parse();
   
} catch (Zend_Console_Getopt_Exception $e) {
    exit($e->getMessage() ."\n\n". $e->getUsageMessage());
}

if(isset($opts->h)) {
    echo $opts->getUsageMessage();
    exit;
}

if(isset($opts->test)) {
}


if(isset($opts->a)) {
    $reqRoute = array_reverse(explode('.',$opts->a));
    @list($action,$controller) = $reqRoute;
    
    $request = new Zend_Controller_Request_Simple($action,$controller,'default');
    $front = Zend_Controller_Front::getInstance();

    $front->setControllerDirectory(
        array(
            'default' => './../application/controllers'
        )
    );
    
    
    
    
    $front->setRequest($request);
    $front->setRouter(new Lib_Controller_Router_Cli());

    $front->setResponse(new Zend_Controller_Response_Cli());

    $front->throwExceptions(true);
    
    $front->addModuleDirectory('./../application/');
   
    $front->dispatch();
}